-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move the sidebar to be stuck to left of the content #999
Conversation
2166c29
to
54b200c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the new style very much! The previous side bar was invisible. This feels more conventional.
There was unwanted margin when the window is half-width that was probably here to accommodate the previous side bar. I have an improved margin/padding in this branch: https://github.com/Julow/odoc/tree/999-review
Feel free to cherry-pick.
height: fit-content; | ||
border: solid 1px var(--border); | ||
border-radius: 5px; | ||
position:sticky; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sticky is interesting but it has a behavior I find confusing:
If the side bar is longer than the screen is high but is smaller than the content, it's not possible to see the bottom of the side bar until we reach the bottom of the page.
Is here a way to make the side bar sticky only if the bottom of it is visible ?
Otherwise, I think I slightly prefer having a unsticky side bar. It's much more intuitive.
Note: We might make the side bar longer in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is here a way to make the side bar sticky only if the bottom of it is visible ?
I agree that would be nice. It is certainly possible with javascript. I will look for a css only solution.
I think the sticky is important because the bar is use for navigation inside the page itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another solution is to have a maximal height for the left bar of the size of height, and add a scroll bar.
However, I do not love any of the solution!
- Sticky, bottom of long nav bar inaccessible unless at the bottom of the page is a "no" for me
- "Custom stickiness", with some js solving the above problem: why not, but not very satisfying to have to use JS.
- Not sticky: simple and works, but not the best since we quickly lose the table of content in long pages
I'll be ok with those last two solutions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no perfect solution and I think the scrollable side bar is the best compromise of usability and simplicity.
src/html_support_files/odoc.css
Outdated
max-width: 100ex; | ||
max-width: 122ex; | ||
display: grid; | ||
grid-template-columns: 28ex 90ex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the goal of this? Shouldn't the other property already control the width ?
This cause overflow when the window is half the width of my screen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how the grid layout usually work, but there this the fr
unit I should use here for small width cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The grid elements definitely have a size already. Removing this property removes the overflow in my testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you are in fact right, the content does not have a width, but the sidebar does, and the body has a max witdh.
I notified the ocamlorg team about this issue in case they got some insight about the css |
src/html_support_files/odoc.css
Outdated
.odoc-content > *:first-child { | ||
/* This make the first thing in the content align with the sidebar */ | ||
padding-top: 0; | ||
margin-top: 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I see what you mean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ! indeed. This is unrelated to that particular rule though. This can be changed by tweaking the grid layout (grid-row and grid-columns rules) (and if we do this rule becomes useless)
I agree it is a bit weird like that, but I think I still like it. I will ponder that a bit more.
height: fit-content; | ||
border: solid 1px var(--border); | ||
border-radius: 5px; | ||
position:sticky; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another solution is to have a maximal height for the left bar of the size of height, and add a scroll bar.
However, I do not love any of the solution!
- Sticky, bottom of long nav bar inaccessible unless at the bottom of the page is a "no" for me
- "Custom stickiness", with some js solving the above problem: why not, but not very satisfying to have to use JS.
- Not sticky: simple and works, but not the best since we quickly lose the table of content in long pages
I'll be ok with those last two solutions.
On |
@gpetiot I do not think the css you linked to me would be able to achieve the result I desire, at least not without changing the html. I think Sabine's suggestion would fix the issue you mentionned. |
24e73e8
to
1c120e5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the new side bar as it is now :) I'm in favor of merging.
This needs rebasing. I tried a "naive" resolution of conflicts, but it makes the search bar at the bottom of the page... |
1c120e5
to
ef2ea1c
Compare
--toc-top: 20px; | ||
|
||
/* TODO : make this smaller if there is no search bar */ | ||
--toc-top: calc(var(--search-bar-height) + var(--search-padding-top) + 20px); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the search bar sticky as well ? If not, this is not needed at all, --toc-top: 20px
is sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately the search bar is sticky and I find that not satisfying. The search bar takes valuable vertical space and is not properly spaced from the content is hovers. It's only surrounded by a white shadow that makes it hard to spot where the contents begins and doesn't fit with Odoc's theme.
When the search bar is not present, this calculation adds space above the TOC that doesn't look good either.
I suggest making the search bar non sticky to fix all of that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is not properly spaced from the content is hovers
i do not understand this part
When the search bar is not present, this calculation adds space above the TOC that doesn't look good
either.
I can fix this.
It's only surrounded by a white shadow that makes it hard to spot where the contents begins
This is probably fixable, although I do not remember having this issue
doesn't fit with Odoc's theme.
Its true the input element is practically unstyled, but I plan to style it in my colors pr. As of now, it is dependent on browser defaults, which are very different and sometimes ugly.
I like the sticky sidebar, for the reason that I think that searching for something while looking at the doc is very useful. If it is not sticky, if you read the doc and the want to search for something, then you have to scroll to the top, and might forget what you wanted to do, and you also cannot type the query while looking at the doc (for instance copying a typename in a type-search query).
Also, the sidebar was not made sticky by this PR, and changing it is a little out of scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is not properly spaced from the content is hovers
I mean that it's hard to distinguish where the content starts below the search bar.
If it is not sticky, if you read the doc and the want to search for something, then you have to scroll to the top, and might forget what you wanted to do, and you also cannot type the query while looking at the doc
I don't think this workflow is well implemented currently. The dropdown showing the search results is above the page and might interfere. On mobile, almost none of the page is visible while typing the search query.
This waste vertical space at all time, not just when I intent to search.
Also, the sidebar was not made sticky by this PR, and changing it is a little out of scope.
Agree! I just noticed that the search bar was sticky while reviewing this calculation. Let's not do change the search bar in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On mobile, almost none of the page is visible while typing the search query.
True, the search bar should not be sticky on mobile
This waste vertical space at all time, not just when I intent to search.
That is true, there is a tradeoff here. Maybe with some js magic we can have both, but I am not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would trade having to scroll to the top for more vertical space.
This needs an other rebase. I think the commits could be squashed as the history is currently a bit messy. |
Unfortunately, this does not work.
I have pushed a fix for this. |
dd9a39e
to
2585477
Compare
I have squashed everything, I believe this is now ready for merging |
38ed355
to
b153813
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a rebase and then can be merged.
I'd like a comment in the code if you have the time.
@@ -759,19 +783,29 @@ td.def-doc *:first-child { | |||
line-height: 1.2; | |||
} | |||
|
|||
.odoc-search + * + .odoc-toc { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment saying that this is to accommodate the sidebar would be useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is done
b153813
to
51baa29
Compare
Perfect, let's merge! |
CHANGES: ### Added - Add support for external search engines (@panglesd, @EmileTrotignon, ocaml/odoc#972) This includes the generation of an index and the display of the results in the UI (HTML only). - Display 'private' keyword for private type extensions (@gpetiot, ocaml/odoc#1019) - Allow to omit parent type in constructor reference (@panglesd, @EmileTrotignon, ocaml/odoc#933) ### Fixed - Warn and exit when table(s) is not closed (@lubegasimon, ocaml/odoc#1050) - Hint when list(s) is not closed (@lubegasimon, ocaml/odoc#1050) - Fix crash on functors returning an alias (@Julow, ocaml/odoc#1046) - Fix rendering of polymorphic variants (@wikku, @panglesd, ocaml/odoc#971) - Add references to extension declarations (@gpetiot, @panglesd, ocaml/odoc#949) ### Changed - Style: Adjusted line height in the TOC to improve readability (@sorawee, ocaml/odoc#1045) - Style: Remove font fallback to Helvetica, Arial (@Julow, ocaml/odoc#1028) - Style: Preformatted elements fallback to UA monospace (@toastal, ocaml/odoc#967) - Style: Sidebar is now stuck to the left of the content instead of the left of the viewport (@EmileTrotignon, ocaml/odoc#999)
CHANGES: ### Added - Add support for external search engines (@panglesd, @EmileTrotignon, ocaml/odoc#972) This includes the generation of an index and the display of the results in the UI (HTML only). - Display 'private' keyword for private type extensions (@gpetiot, ocaml/odoc#1019) - Allow to omit parent type in constructor reference (@panglesd, @EmileTrotignon, ocaml/odoc#933) ### Fixed - Warn and exit when table(s) is not closed (@lubegasimon, ocaml/odoc#1050) - Hint when list(s) is not closed (@lubegasimon, ocaml/odoc#1050) - Fix crash on functors returning an alias (@Julow, ocaml/odoc#1046) - Fix rendering of polymorphic variants (@wikku, @panglesd, ocaml/odoc#971) - Add references to extension declarations (@gpetiot, @panglesd, ocaml/odoc#949) ### Changed - Style: Adjusted line height in the TOC to improve readability (@sorawee, ocaml/odoc#1045) - Style: Remove font fallback to Helvetica, Arial (@Julow, ocaml/odoc#1028) - Style: Preformatted elements fallback to UA monospace (@toastal, ocaml/odoc#967) - Style: Sidebar is now stuck to the left of the content instead of the left of the viewport (@EmileTrotignon, ocaml/odoc#999)
CHANGES: ### Added - Add support for external search engines (@panglesd, @EmileTrotignon, ocaml/odoc#972) This includes the generation of an index and the display of the results in the UI (HTML only). - Display 'private' keyword for private type extensions (@gpetiot, ocaml/odoc#1019) - Allow to omit parent type in constructor reference (@panglesd, @EmileTrotignon, ocaml/odoc#933) ### Fixed - Warn and exit when table(s) is not closed (@lubegasimon, ocaml/odoc#1050) - Hint when list(s) is not closed (@lubegasimon, ocaml/odoc#1050) - Fix crash on functors returning an alias (@Julow, ocaml/odoc#1046) - Fix rendering of polymorphic variants (@wikku, @panglesd, ocaml/odoc#971) - Add references to extension declarations (@gpetiot, @panglesd, ocaml/odoc#949) ### Changed - Style: Adjusted line height in the TOC to improve readability (@sorawee, ocaml/odoc#1045) - Style: Remove font fallback to Helvetica, Arial (@Julow, ocaml/odoc#1028) - Style: Preformatted elements fallback to UA monospace (@toastal, ocaml/odoc#967) - Style: Sidebar is now stuck to the left of the content instead of the left of the viewport (@EmileTrotignon, ocaml/odoc#999)
CHANGES: ### Added - Add support for external search engines (@panglesd, @EmileTrotignon, ocaml/odoc#972) This includes the generation of an index and the display of the results in the UI (HTML only). - Display 'private' keyword for private type extensions (@gpetiot, ocaml/odoc#1019) - Allow to omit parent type in constructor reference (@panglesd, @EmileTrotignon, ocaml/odoc#933) ### Fixed - Warn and exit when table(s) is not closed (@lubegasimon, ocaml/odoc#1050) - Hint when list(s) is not closed (@lubegasimon, ocaml/odoc#1050) - Fix crash on functors returning an alias (@Julow, ocaml/odoc#1046) - Fix rendering of polymorphic variants (@wikku, @panglesd, ocaml/odoc#971) - Add references to extension declarations (@gpetiot, @panglesd, ocaml/odoc#949) ### Changed - Style: Adjusted line height in the TOC to improve readability (@sorawee, ocaml/odoc#1045) - Style: Remove font fallback to Helvetica, Arial (@Julow, ocaml/odoc#1028) - Style: Preformatted elements fallback to UA monospace (@toastal, ocaml/odoc#967) - Style: Sidebar is now stuck to the left of the content instead of the left of the viewport (@EmileTrotignon, ocaml/odoc#999)
CHANGES: ### Added - Add support for external search engines (@panglesd, @EmileTrotignon, ocaml/odoc#972) This includes the generation of an index and the display of the results in the UI (HTML only). - Display 'private' keyword for private type extensions (@gpetiot, ocaml/odoc#1019) - Allow to omit parent type in constructor reference (@panglesd, @EmileTrotignon, ocaml/odoc#933) ### Fixed - Warn and exit when table(s) is not closed (@lubegasimon, ocaml/odoc#1050) - Hint when list(s) is not closed (@lubegasimon, ocaml/odoc#1050) - Fix crash on functors returning an alias (@Julow, ocaml/odoc#1046) - Fix rendering of polymorphic variants (@wikku, @panglesd, ocaml/odoc#971) - Add references to extension declarations (@gpetiot, @panglesd, ocaml/odoc#949) ### Changed - Style: Adjusted line height in the TOC to improve readability (@sorawee, ocaml/odoc#1045) - Style: Remove font fallback to Helvetica, Arial (@Julow, ocaml/odoc#1028) - Style: Preformatted elements fallback to UA monospace (@toastal, ocaml/odoc#967) - Style: Sidebar is now stuck to the left of the content instead of the left of the viewport (@EmileTrotignon, ocaml/odoc#999)
I propose to change the position of the sidebar that contains the table of content to be closer to the content.
It used to be like that :
Here, the sidebar is quite far from the content. With a smaller screen this may be better.
My proposal is the following :
I think it is better for multiple reasons. First of all, you need to move your eyes and mouse less to use the table of content. Also, the previous design did not make it clear that the sidebar contained the table of content for the current page. Because of its position, it felt like a general sidebar for the whole website, and not linked to the current content. My proposal alleviate that issue by placing putting the sidebar closer to the content and under the title of the page.
It would also allow for a more consensual design for the search bar in #972